package com.jetinno.jetinnosystem;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;

/**
 * Created by zhangyuncai.
 * Date: 2022/4/22
 * 开机结束后启动APP
 */
public class BootFinishReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        if (TextUtils.equals(HbConstant.BOOT_COMPLETED_ACTION, action) ||
                TextUtils.equals(HbConstant.BOOT_IPO_ACTION, action)) {
            launchApp(context);
        }
    }

    private void launchApp(Context context) {
        Intent launch = new Intent(context, MainActivity.class);
        launch.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(launch);
    }
}
